﻿--HEADER Diary Entry FTS
CREATE TABLE [iPerform].[Tag_Tmp]
    (
      Id int NOT NULL IDENTITY(1, 1),
      Name nvarchar(50) NULL
    )
ON  [PRIMARY]
GO

SET IDENTITY_INSERT [iPerform].[Tag_Tmp] ON
GO

IF EXISTS ( SELECT  *
            FROM    [iPerform].[Tag] ) 
    INSERT  INTO [iPerform].[Tag_Tmp] ( Id, Name )
            SELECT  Id,
                    Name
            FROM    [iPerform].[Tag] TABLOCKX
GO

SET IDENTITY_INSERT [iPerform].[Tag_Tmp] OFF
GO

DROP TABLE [iPerform].[Tag]
GO

Exec sp_rename '[iPerform].[Tag_Tmp]', 'Tag'

GO
alter table [iPerform].[Tag]
add constraint PK_Tag Primary key (Id)